
<template>
  <div>
    <HeaderTitle :nologin="nologin" :secondPage="secondPage"></HeaderTitle>
    <logoComponent v-show="showtitle"  :secondPage="secondPage"></logoComponent>
    <navComponent v-show="showtitle"  v-if="!secondPage"></navComponent>
    <keep-alive>
      <nuxt-child @submit="submit"/>
    </keep-alive>
    <footerComponent  v-show="showtitle"></footerComponent>
    <contactusAlert @closealert="closealert" :showalert="showalert"></contactusAlert>
    <loginRegistered :nologin="nologin" @closedialog="closedialog"></loginRegistered>
  </div>
</template>
<script>



import HeaderTitle from "../components/HeaderTitle";
import logoComponent from "../components/logoComponent";
import navComponent from "../components/navComponent";
import loginRegistered from "../components/loginRegistered";
import footerComponent from "../components/footerComponent";
import contactusAlert from "../components/contactusAlert";

import { mapState } from "vuex";
import api from '../static/js/api.js';
var j,s;
var timeoutcon;
var closenum = 0;
export default {
  transition: "test",
  scrollToTop: true,
  components: {
    HeaderTitle,
    logoComponent,
    navComponent,
    loginRegistered,
    footerComponent,
    contactusAlert
  },
  data(){
    return{
        showalert:false,
        showtitle:true
    }
  },
  methods:{
  
     submit(){
         this.showalert = true
     },
    closealert(){
        this.showalert = false
    },
      getUserInfo(){
            if(this.$store.state.nologin){
                    this.$store.state.showlogin = true;
                    this.$store.state.userinfo = {};
                }  
     },
    closedialog(){
      closenum ++;
      clearTimeout(timeoutcon)
      this.$store.state.showlogin = false;
      if(closenum == 1){
       timeoutcon = setTimeout(this.getUserInfo, 10000);
      }else if(closenum > 1){
       timeoutcon = setTimeout(this.getUserInfo, 5000);
      }
    }
  },
  computed: {
    ...mapState(["nologin", "secondPage"])
  },
  mounted: function() {
     
    var href = window.location.href;

    if( href.indexOf("add5") != -1 ){ 
              this.showtitle = false
    }
    if (localStorage.nologin == "false") {
            this.$store.state.nologin = false;
            this.$store.state.showlogin = false;
            this.$store.state.userinfo = JSON.parse(localStorage.userinfo);
    }else{
       if( href.indexOf("add5") != -1 ){ 
              this.getUserInfo()
        }
    }

          window['_MEIQIA'] = window['_MEIQIA'] || function () {
              (window['_MEIQIA'].a = window['_MEIQIA'].a || []).push(arguments)
          };
          j = document.createElement('script'),
          s = document.getElementsByTagName('script')[0];
          j.async = true;
          j.charset = 'UTF-8';
          j.src = 'https://static.meiqia.com/dist/meiqia.js?_=t';
          s.parentNode.insertBefore(j, s);
      
          _MEIQIA('entId', 103141);
          _MEIQIA('withoutBtn');
          _MEIQIA('allSet', function () {
              var __outerBtn = document.getElementById('xxx');
              __outerBtn.onclick = function () {
                  _MEIQIA('showPanel');
              };
             // _MEIQIA('showPanel');
          });
  }
};
</script>

